package com.wanmait.demo.webcontroller.usercontroller;

import com.github.pagehelper.PageInfo;
import com.wanmait.demo.pojo.Component;
import com.wanmait.demo.service.ComponentService;
import com.wanmait.demo.service.ConfigService;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

//零件
@Controller
public class ComponentController {
@Resource
private ComponentService componentService;

@Resource
private ConfigService configService;
//零件页面
    @RequestMapping("/component")

    public ModelAndView component(Integer PageNum){

        int pagesize=configService.componentpagrcount();

        if(PageNum==null)
        {
           PageNum=1;
        }

            PageInfo<Component> components=componentService.findPagecomponent(PageNum,pagesize);


        ModelAndView modelAndView=new ModelAndView();
        modelAndView.setViewName("user/ysk/component");
        modelAndView.addObject("components",components );
        return modelAndView;

    }
}
